<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$ci = & get_instance();
	if(!isUserLogin()){
		redirect(site_url());exit();
	}
	$USER = $ci->user_entity->init('id',getUserId());
?>
<form action="<?php echo site_url('cricket/account/verify_cod_submit');?>" name="verify_cod_submit" id="verify_cod_submit" method="post" enctype="multipart/form-data" >
<div id="center_content">
	<div class="clrboth"></div>
	<div class="block">
		<div class="title" style="position:relative;">
			<h3 class="bold"><a href="<?php echo site_url("cricket/user/dashboard")?>">Dashboard</a> &raquo; Add CX coins</h3>
			<a class="back_button2" href="<?php echo site_url("cricket/user/dashboard")?>" title="Back?">Back?</a>	
		</div>
		<div class="clrboth"></div>
		<div class="content">
			<div class="rowitem3">
				<div class="clrboth"></div>
					<?php $this->load->view('cricket/user/payment_modes'); ?>
				<div class="clrboth"></div>	
				<br/>
				You must verify your delivery information via mobile phone firstly.
				<div class="clrboth"></div>	
				<br/>
				
				<div class="clrboth"></div>
				<div class="grid2"><span class="bold">*Mobile phone number:</span></div>
				<div class="grid6"><input type="text" maxlength="10" id="cod_mobile" name="cod_mobile" value="<?php echo $USER->getCodMobile();?>" class="std-input"/></div>
				<div class="grid2"><span class="bold red hidden" id="cod_mobile_error">Required field.</span></div>
				<div class="clrboth"></div>
				
				<div class="clrboth"></div>
				<div class="grid2"><span class="bold">*Address:</span></div>
				<div class="grid6">
					<textarea maxlength="255" id="cod_address" name="cod_address" style="width:250px;height:100px;margin:5px;"><?php echo $USER->getCodAddress();?></textarea>
				</div>
				<div class="grid2"><span class="bold red hidden" id="cod_address_error">Required field.</span></div>
				<div class="clrboth"></div>
				
				<div class="clrboth"></div>
				<div class="grid2"><span class="bold">*City:</span></div>
				<div class="grid6"><input type="text" maxlength="255" id="cod_city" name="cod_city" value="<?php echo $USER->getCodCity();?>" class="std-input"/></div>
				<div class="grid2"><span class="bold red hidden" id="cod_city_error">Required field.</span></div>
				<div class="clrboth"></div>
				
				<div class="clrboth"></div>
				<div class="grid2"><span class="bold">*State:</span></div>
				<div class="grid6"><input type="text" maxlength="255" id="cod_state" name="cod_state" value="<?php echo $USER->getCodState();?>" class="std-input"/></div>
				<div class="grid2"><span class="bold red hidden" id="cod_state_error">Required field.</span></div>
				<div class="clrboth"></div>
				
				<div class="clrboth"></div>
				<div class="grid2"><span class="bold">*Postal Code:</span></div>
				<div class="grid6"><input type="text" maxlength="6" id="cod_postalcode" name="cod_postalcode" value="<?php echo $USER->getCodePostalCode();?>" class="std-input"/></div>
				<div class="grid2"><span class="bold red hidden" id="cod_postalcode_error">Required field.</span></div>
				<div class="clrboth"></div>
				
				<div class="grid2">&nbsp;</div>
				<div class="grid6" style="margin-bottom:50px;"><input type="submit" class="submitclass" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
				<div class="clrboth"></div>	
			 
				<div class="grid2">&nbsp;</div>
				<div class="grid6 red" id="system_error"></div>
				<div class="clrboth"></div>	
			</div>	
		</div>
	</div>	
	<div class="clrboth"></div>
</div>
</form>

<script type="text/javascript">
	google.setOnLoadCallback(function() {
		$('#cod_payment').addClass('current');
		var option = { 
			beforeSubmit:  validateBeforeSubmit,  
			success: processAfterSubmit
		};	
		$('#verify_cod_submit').ajaxForm(option);
	});
	
	function validateBeforeSubmit(formData, jqForm, options){
		$('#loader_image').show();
		$('#cod_mobile_error, #cod_address_error, #cod_city_error, #cod_state_error, #cod_postalcode_error').hide();
		return true;
	}
	
	function processAfterSubmit(responseText, statusText, xhr, $form){
		$('#loader_image').hide();
		var p = new PHP_JS();
		var result_arr = p.explode('#',responseText); 
		if(result_arr[0] == 'msg'){
			$('#system_error').html(result_arr[1]).show();
		}else if(result_arr[0] == 'err'){
			for(i in result_arr){
				$('#'+result_arr[i]).show();
			}
		}else if(result_arr[0] == 'ok'){
			queryURL(BASE_URI+MODULE+'/account/cod_verify1');
		}
	}
</script>
